<?php

namespace Plugin\Attractions\HaiKang\Process;

use Hyperf\Coroutine\Coroutine;
use Hyperf\Di\Annotation\Inject;
use Hyperf\Process\AbstractProcess;
use Hyperf\Process\Annotation\Process;
use Plugin\Attractions\HaiKang\Service\HKDeviceService;

/**
 * 海康设备定时更新
 */
#[Process(name: "SycHKDevice")]
class SycHKDevice extends AbstractProcess
{
    #[Inject()]
    private HKDeviceService $service;
    public function handle(): void
    {
        Coroutine::create(function () {
            Coroutine::sleep(10);
            while (true) {
                try {
                    $this->service->syncDevices([]);
                    Coroutine::sleep(600);
                } catch (\Exception $e) {
                    Coroutine::sleep(600);
                } 
            }
        });
    }

    public function isEnable($server): bool
    {
        return false;
    }
}